const router = require("express-promise-router")();

const LogService = require("../../services/log");
const EmoocService = require("../../services/emooc");

router.post('/remove',async (req,res) => {
    const {bindId} = req.body;
    try{
        await EmoocService.unBindDevice(bindId);
        res.json({status:200,message: '解绑成功'})
    } catch(e) {
        res.json({status:400,message: '解绑失败'})
    }
});

router.post('/bind',async (req,res) => {
    const {deviceId,username} = req.body;
    try{
        await EmoocService.bindDevice(deviceId,username);
        res.json({status:200,message: '绑定成功'})
    } catch(e) {
        res.json({status:400,message: '绑定失败'})
    }
});

module.exports = router;